home *** CD-ROM | disk | FTP | other *** search
- Path: mavetju.iaehv.nl!edwin
- From: edwin@mavetju.iaehv.nl (Edwin Groothuis)
- Newsgroups: comp.lang.c,comp.os.os2.programmer.misc,comp.programming,fido7.os2.prog,sfnet.atk.os2
- Subject: Re: Playing *.wav files with OS/2
- Distribution: world
- Message-ID: <825627040edwin.term@mavetju.iaehv.nl>
- Sender: term@mavetju.iaehv.nl
- Date: Thu, 29 Feb 96 20:50:40 GMT
- References: <4h2fap$9sa@nic.dataphone.se>
- Organization: MavEtJu software, the Netherlands
- X-Newsreader: TRN for OS/2
-
- In article <4h2fap$9sa@nic.dataphone.se> skorpio@dataphone.se writes:
- >If anyone could help me with playing *.wav files in OS/2. What I want to
- >do is that when the user presses a dialog button the utility plays a tune
- >( a .wav file ).
-
- #define INCL_OS2MM
- #define INCL_MCIOS2
- #define INCL_DOSPROCESS
-
- #include <os2emx.h>
- #include <mmos2/os2me.h> <-- do you have this?
- #include <stdio.h>
- #include <malloc.h>
- #include <stdlib.h>
- #include <strings.h>
- #include "mmedia.h"
-
-
- typedef struct THREADINFO { ULONG ulSzStruct;
- BOOL bKillThread;
- HAB habThread;
- BOOL bThreadDead;
- BOOL bResult;
- } THREADINFO,*PTHREADINFO;
- typedef struct WAVTHREADINFO { THREADINFO ti;
- CHAR WavFile[100];
- BOOL continues;
- } WAVTHREADINFO, *PWAVTHREADINFO;
-
-
- ULONG MCIinterface(char *buff)
- {
- const rsize = 128;
- char rbuff[rsize];
- ULONG rc;
-
- bzero(rbuff,rsize);
-
- rc = mciSendString(buff, /* buffer with MCI string */
- rbuff, /* return buffer */
- rsize, /* rbuff size */
- 0, /* no callback window handle */
- 0); /* no user parameter */
- if (rc == MCIERR_SUCCESS)
- if (rbuff[0]!='1')
- return 1;
- return (rc);
- }
-
-
- void openPlayWavThread(PWAVTHREADINFO potiInfo)
- {
- HAB hab;
- HMQ hmq;
-
- hab=WinInitialize(0);
- hmq=WinCreateMsgQueue(hab,0);
- WinCancelShutdown(hmq,TRUE);
-
- potiInfo->ti.habThread=hab;
- potiInfo->ti.bThreadDead=FALSE;
- potiInfo->ti.bResult=FALSE;
-
- {
- char s[100];
-
- if (MCIinterface("open waveaudio alias wave shareable wait")!=0)
- return;
- sprintf(s,"load wave %s",potiInfo->WavFile);
- MCIinterface(s);
- MCIinterface("play wave wait");
- MCIinterface("close wave wait");
- }
- WinDestroyMsgQueue(hmq);
- WinTerminate(hab);
- /* DosEnterCritSec();*/
- }
-
-
- void PlayWav(char *wav,BOOL continues)
- {
- THREADINFO ptiInput;
- PVOID pfnThread;
- PVOID pvParm;
- PWAVTHREADINFO potiInfo;
- static PWAVTHREADINFO WavThreadInfo=NULL;
-
- ptiInput.bKillThread=FALSE;
-
- ptiInput.ulSzStruct=sizeof(WAVTHREADINFO);
- potiInfo=(PWAVTHREADINFO)malloc(sizeof(WAVTHREADINFO));
- memcpy(potiInfo,&ptiInput,sizeof(THREADINFO));
- pfnThread=openPlayWavThread;
- pvParm=(PVOID)potiInfo;
- strcpy(potiInfo->WavFile,wav);
- potiInfo->continues=continues;
- WavThreadInfo=potiInfo;
-
- if (_beginthread(pfnThread,NULL,0x4000,pvParm)==-1)
- {
- free(pvParm);
- WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,
- "The thread could not be created (openPlayWavThread)", "Error",
- 0, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE);
- return;
- }
- }
-
- Edwin `can somebody tell me why this thread sometimes doesn't stop when
- I'm playing a large wavfile?' G.
-
- --
- Edwin Groothuis OS/2: Drag me, drop me, make me feel like an object!
- 2:284/205.1@fidonet
- edwin@mavetju.iaehv.nl URL: http://www.iaehv.nl/users/mansion/edwin.html
-